﻿using System.Collections.Generic;

/// <summary>
/// 
/// </summary>
public class IDataItem
{
    /// <summary>
    /// 唯一ID
    /// <summary>
    //public int Id { get; private set; }

    //public void Init(ExcelLineReader reader)
    //{
    //    Id = reader.ReadInt();
    //}
}

/// <summary>
/// 
/// </summary>
public class IDataMgr
{
    public int DataCount { get; private set; }
    protected virtual string FileName { get { return ""; } }
    public virtual void Load(ExcelLineReader reader) { }

    protected List<IDataItem> mItemList = new List<IDataItem>();
    protected T GetItemByIdx<T>(int idx) where T : IDataItem
    {
        return mItemList[idx] as T;
    }

    public void Init()
    {
        DataCount = 0; var reader = new ExcelReader();
        if (!reader.LoadFile(FileName))
        {
            reader.Clear(); return;
        }

        var lineReader = reader.ReadLine();
        while (lineReader != null)
        {
            Load(lineReader); DataCount++;
            lineReader = reader.ReadLine();
        }
        reader.Clear();
    }
}